import request from '@/utils/request'
import { camelCaseObject } from '@/libs/object'

const AUTH_PREFIX_V1 = `/api/v1/transfer`

export function getTransferJobList(params) {
  return request.get(`${AUTH_PREFIX_V1}/jobs`, { params }).then(res => camelCaseObject(res))
}

export function getTransferJobListByPage(params) {
  return request.get(`${AUTH_PREFIX_V1}/jobs/page`, { params }).then(res => camelCaseObject(res))
}

export function getTransferJob(jobId) {
  return request.get(`${AUTH_PREFIX_V1}/jobs/${jobId}`).then(res => camelCaseObject(res))
}

export function createTransferJob(params) {
  return request.post(`${AUTH_PREFIX_V1}/jobs`, params).then(res => camelCaseObject(res))
}

export function updateTransferJob(jobId, params) {
  return request.put(`${AUTH_PREFIX_V1}/jobs/${jobId}`, params).then(res => camelCaseObject(res))
}

export function executeTransferJob(jobId, params) {
  return request.put(`${AUTH_PREFIX_V1}/jobs/${jobId}/execute`, params).then(res => camelCaseObject(res))
}

export function deleteTransferJob(jobId) {
  return request.delete(`${AUTH_PREFIX_V1}/jobs/${jobId}`).then(res => camelCaseObject(res))
}
